import 'package:flutter/material.dart';
import './tab_info/index.dart';
import './tab_search/index.dart';
import '../../widgets/page_content.dart';
import './tab_index/index.dart';
import './tab_profile/index.dart';

List<Widget> tabview = [
  TabIndex(),
  // PageContent(name: '首页',),
  TabSearch(),
  // PageContent(name: '搜索',),
  Tabinfo(),
  // PageContent(name: '资讯',),
  TabProfile()
  // PageContent(name: '我的',),
];

List<BottomNavigationBarItem> barItemList=[
  BottomNavigationBarItem(title:Text('首页'),icon: Icon(Icons.home)),
  BottomNavigationBarItem(title:Text('搜索'),icon: Icon(Icons.search)),
  BottomNavigationBarItem(title:Text('资讯'),icon: Icon(Icons.info)),
  BottomNavigationBarItem(title:Text('我的'),icon: Icon(Icons.account_circle)),
];

class HomePage extends StatefulWidget {
  const HomePage({ Key key }) : super(key: key);

  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  int _selectedIndex=0;
  void _onItemTapped(int index) {
    setState(() {
      _selectedIndex = index;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: tabview[_selectedIndex],
      bottomNavigationBar: BottomNavigationBar(
        items: barItemList,
        currentIndex: _selectedIndex,
        type: BottomNavigationBarType.fixed,
        selectedItemColor: Colors.green,
        onTap: _onItemTapped
      ),
    );
  }
}
